package org.neframework.test.core;

import java.util.List;
import java.util.Map;

import org.neframework.test.db.DatabaseApplication;

import com.tmsps.neframework.core.utils.JsonTools;

/**
 * 备份工具类
 * 
 * @author 冯晓东
 *
 */
public class BackupTools {

	public static void main(String[] args) {
		String databaseInfo = BackupTools.getDatabaseInfoJson();
		System.err.println(databaseInfo);

	}

	public static List<Map<String, Object>> getDatabaseInfo() {
		// TODO 获取数据库信息
		DatabaseApplication metaData = new DatabaseApplication();

		List<Map<String, Object>> tableList = metaData.getAllTableList(null);

		for (Map<String, Object> table : tableList) {
			String TABLE_NAME = (String) table.get("TABLE_NAME");
			System.err.println(TABLE_NAME);
			List<Map<String, Object>> columns = metaData.getTableColumns(null, TABLE_NAME);
			table.put("columns", columns);
		}// #for tableList

		return tableList;
	}

	public static String getDatabaseInfoJson() {
		return JsonTools.toJson(getDatabaseInfo());
	}

}
